// This file is part of Indico.
// Copyright (C) 2002 - 2025 CERN
//
// Indico is free software; you can redistribute it and/or
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.

@use 'base/flex' as *;
@use 'base/palette' as *;
@use 'base/typography' as *;
@use 'base/utilities' as *;

@mixin line-style {
  line-height: 2em;
  padding: 0.25em 0;
  margin: 0;
}

.event-log {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1em;

  .toolbars {
    display: flex;
  }

  .paginator {
    display: flex;

    .i-button {
      line-height: normal;
    }
  }

  .info-message-box {
    margin-top: 1em;
  }
}

.event-log-list-spinner {
  position: absolute;
  font-size: 5em;
  left: 45%;
  top: 250px;
}

.event-log-list {
  display: flex;
  flex-direction: column;
  list-style-type: none;
  color: $black;

  &.loading {
    background-color: #fff;
    opacity: 0.2;
    pointer-events: none;
  }

  li.log-realm-admin span.log-module span.log-icon i.log-realm {
    @include icon-before('icon-settings');
  }

  li.log-realm-emails span.log-module span.log-icon i.log-realm {
    @include icon-before('icon-mail');
  }

  li.log-realm-event span.log-module span.log-icon i.log-realm {
    @include icon-before('icon-time');
  }

  li.log-realm-reviewing span.log-module span.log-icon i.log-realm {
    @include icon-before('icon-user-reading');
  }

  li.log-realm-participants span.log-module span.log-icon i.log-realm {
    @include icon-before('icon-users');
  }

  li.log-realm-acl span.log-module span.log-icon i.log-realm {
    @include icon-before('icon-shield');
  }

  li.log-realm-system span.log-module span.log-icon i.log-realm {
    @include icon-before('icon-wrench');
  }

  li.log-realm-user span.log-module span.log-icon i.log-realm {
    @include icon-before('icon-user');
  }

  li.log-realm-management span.log-module span.log-icon i.log-realm {
    @include icon-before('icon-medal');
  }

  li.log-kind-positive span.log-module span.log-icon i.log-kind,
  li.log-realm-emails.log-kind-positive span.log-module span.log-icon {
    color: $green;
  }

  li.log-kind-negative span.log-module span.log-icon i.log-kind,
  li.log-realm-emails.log-kind-negative span.log-module span.log-icon {
    color: $red;
  }

  li.log-kind-change span.log-module span.log-icon i.log-kind,
  li.log-realm-emails.log-kind-change span.log-module span.log-icon {
    color: $blue;
  }

  li.log-kind-other span.log-module span.log-icon i.log-kind,
  li.log-realm-emails span.log-module span.log-icon i.log-kind {
    display: none;
  }

  > li {
    @include line-style();
    display: flex;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid $pastel-gray;

    .log-module {
      @extend .flexrow;

      display: flex;
      flex: 0.6;

      .log-icon {
        display: flex;
        color: $dark-gray;
        font-size: 1.2em;
        position: relative;
        width: 1.8em;

        i.log-kind {
          line-height: 1em;
          font-size: 0.7em;
          position: absolute;
          right: 3px;
          top: 1px;
        }
      }
    }

    .log-entry-description {
      cursor: pointer;
      flex: 2 0 0%;
      word-wrap: break-word;
      text-decoration: dotted underline $gray;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .log-entry-details {
      @include text-superfluous();

      display: flex;
      flex: 0.65;
      align-items: center;
      justify-content: space-between;
      margin-left: 1em;

      .user-picture {
        opacity: 0.8;
        width: 25px;
        height: 25px;
        border-radius: 50%;
      }

      time {
        vertical-align: middle;
      }
    }
  }
}

.log-modal-author-info {
  margin-top: 1em;
  font-size: 1.2em;

  .log-modal-user,
  .log-modal-time {
    color: $light-black;
  }
}

table.log-modal-details {
  width: 100%;
  margin: 0;

  td.log-caption {
    width: 200px;
  }

  td.email-body .html {
    // For simple Markdown emails where we can simply wrap the text.
    white-space: normal;
    // For custom HTML where wrapping doesn't work, we at least show a scrollbar.
    overflow-x: auto;

    ul,
    ol {
      margin-left: 3em;
    }

    :is(ul, ol) :is(ul, ol) {
      margin-left: 1.2em;
    }
  }

  .diff {
    ins {
      background: $light-green;
      text-decoration: none;
    }

    del {
      background: $light-red;
      text-decoration: none;
    }
  }

  .mail {
    .header,
    .content {
      white-space: normal;
    }
  }
}
